package com.ruoyi.web.xxj.contoller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.xxj.service.IClassOrderService;
import com.ruoyi.web.xxj.service.IPaymentInfoService;
import com.ruoyi.web.xxj.service.IProductOrderService;
import com.ruoyi.web.xxj.service.IRefundInfoService;
import com.ruoyi.web.xxj.service.IWechatUserService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@Api(tags = "首页Controller")
@RestController
@RequestMapping("/xxj/mainPage")
public class MainPageController extends BaseController {

    @Autowired
    private IWechatUserService wechatUserService;
    @Autowired
    private IRefundInfoService refundInfoService;
    @Autowired
    private IPaymentInfoService paymentInfoService;
    @Autowired
    private IClassOrderService classOrderService;
    @Autowired
    private IProductOrderService productOrderService;

    @ApiOperation("获取微信用户数量")
    @GetMapping("/userCount")
    public AjaxResult getWechatUserCount() {
        return AjaxResult.success(wechatUserService.getWechatUserCount());
    }

    @ApiOperation("获取当年支付总额")
    @GetMapping("/payment")
    public AjaxResult toYearPayment() {
        return AjaxResult.success(paymentInfoService.getToYearPayment());
    }

    @ApiOperation("获取当年退款总额")
    @GetMapping("/refund")
    public AjaxResult toYearRefund() {
        return AjaxResult.success(refundInfoService.getToYearRefund());
    }

    @ApiOperation("获取当年课程订单总量")
    @GetMapping("/cOrderCount")
    public AjaxResult toYearClassOrderCount() {
        return AjaxResult.success(classOrderService.getToYearClassOrderCount());
    }

    @ApiOperation("获取当年文创订单总量")
    @GetMapping("/pOrderCount")
    public AjaxResult toYearProductOrderCount() {
        return AjaxResult.success(productOrderService.getToYearProductOrderCount());
    }

    @ApiOperation("近一年微信用户量")
    @GetMapping("/eachMonthUserCount")
    public AjaxResult eachMonthUserCount() {
        return AjaxResult.success(wechatUserService.getEachMonthCountUser());
    }

    @ApiOperation("近一年课程订单量")
    @GetMapping("/eachMonthCOrderCount")
    public AjaxResult eachMonthCOrderCount() {
        return AjaxResult.success(classOrderService.getEachMonthClassOrderNum());
    }

    @ApiOperation("近一年文创订单量")
    @GetMapping("/eachMonthPOrderCount")
    public AjaxResult eachMonthPOrderCount() {
        return AjaxResult.success(productOrderService.getEachMonthProductOrderNum());
    }

    @ApiOperation("近一年收入总额")
    @GetMapping("/eachMonthPayment")
    public AjaxResult eachMonthPayment(@RequestParam(required = true)
    @ApiParam(required = true,value = "类型，classOrder/productOrder") String type) {
        return AjaxResult.success(paymentInfoService.getEachMonthPayment(type));
    }

    @ApiOperation("近一年退款总额")
    @GetMapping("/eachMonthRefund")
    public AjaxResult eachMonthRefund(@RequestParam(required = true)
    @ApiParam(required = true,value = "类型，classOrder/productOrder") String type) {
        return AjaxResult.success(refundInfoService.getEachMonthRefund(type));
    }
}
